<?php

namespace App\Http\Logic\admin;

use App\Model\AdminUserModel;

class LoginLogic{
    // 后台用户登录
    /*
     * 存储数据到 session
       session(['username' => 'admin888']);
       从 session 获取数据
       $value = session('username');
       session()->forget('username'); //清除session 测试用
    */
    public function signInLogic($data){
        $user_model = new AdminUserModel();
        $info = $user_model->getConditionList($data);
        if($info == array()){
            return false;
        }
        session(['username' => $data['username']]);
        return true;
    }
    // 后台注册
    public function registerLogic($data){
        $user_model = new AdminUserModel();
        $user_model->insert_info($data);
        session(['username' => $data['username']]);
        return true;
    }
    // 获取登陆用户信息
    public function userInfoLogic($date){
        $user_model = new AdminUserModel();
        return $user_model->findInfo($date);
    }
}
